## ELF Header
7F 45 4C 46        ## e_ident[EI_MAG0-3] ELF's magic number
02                 ## e_ident[EI_CLASS] Indicating 64 bit
01                 ## e_ident[EI_DATA] Indicating little endianness
01                 ## e_ident[EI_VERSION] Indicating original elf
00                 ## e_ident[EI_OSABI] Set at 0 because none cares
00                 ## e_ident[EI_ABIVERSION] See above
00 00 00 00 00 00 00 ## e_ident[EI_PAD]
02 00              ## e_type Indicating Executable
3E 00              ## e_machine Indicating AMD64
01 00 00 00        ## e_version Indicating original elf
78 00 60 00 00 00 00 00 ## e_entry Address of the entry point
40 00 00 00 00 00 00 00 ## e_phoff Address of program header table
00 00 00 00 00 00 00 00 ## e_shoff Address of section header table
00 00 00 00        ## e_flags
40 00              ## e_ehsize Indicating our 64 Byte header
38 00              ## e_phentsize size of a program header table
01 00              ## e_phnum number of entries in program table
00 00              ## e_shentsize size of a section header table
00 00              ## e_shnum number of entries in section table
00 00              ## e_shstrndx index of the section names

## Program Header table
01 00 00 00             ## p_type
06 00 00 00             ## Flags
00 00 00 00 00 00 00 00 ## p_offset
00 00 60 00 00 00 00 00 ## p_vaddr
00 00 60 00 00 00 00 00 ## Undefined
08 10 00 00 00 00 00 00 ## p_filesz
08 10 00 00 00 00 00 00 ## p_memsz
00 00 20 00 00 00 00 00 ## Required alignment

:_start
CALL *getchar
48 83 f8 ff             # cmp    rax,0xffffffffffffffff
JE ._start.done
CALL *putchar
JMP ._start
:_start.done
48 89 c7                # mov    rdi,rax
MOV_RAX_NUM 3c 00 00 00
SYSCALL

:getchar
MOV_RAX_NUM 00 00 00 00
MOV_RDI_NUM 00 00 00 00
48 8d 35 *buf           # lea    rsi,[rip+0x4a]        # 6000f5 <buf>
MOV_RDI_NUM 01 00 00 00
SYSCALL
48 83 f8 01             # cmp    rax,0x1
JNE .getchar.getchar_fail
MOV_RAX_NUM 00 00 00 00
8a 05 *buf              # mov    al,BYTE PTR [rip+0x2e]        # 6000f5 <buf>
RET
:getchar.getchar_fail
MOV_RAX_NUM ff ff ff ff
RET

:putchar
88 05 *buf              # mov    BYTE PTR [rip+0x1f],al        # 6000f5 <buf>
MOV_RAX_NUM 01 00 00 00
MOV_RDI_NUM 01 00 00 00
48 8d 35 *buf           # lea    rsi,[rip+0xa]        # 6000f5 <buf>
MOV_RDX_NUM 01 00 00 00
SYSCALL
RET

:buf
00 00 00 00 00 00 00 00
